/**
 * 热门搜索
 * @author Qasim <15750783791@163.com>
 * @version 2016/10/21
 */
document.addEventListener('plusready' , ready , false);
var self = '';
var tid = '';
function ready(){
	self = plus.webview.currentWebview();
	tid = self.tid;
	//获取热门搜索关键字
	plus.nativeUI.showWaiting('加载中...');
	$.ajax({
		type :'post',
		url : apiRoot + '/Home/Article/keywords',
		dataType : 'json',
		success : function(data){
			plus.nativeUI.closeWaiting();
			if(data){
				$.each(data, function(k , v) {
					$('.lists').append('<div class="mui-table-view-cell mui-table-view mui-col-xs-4 mui-pull-left" onclick="searchMsg(\''+v+'\')">'+v+'</div>');
				});
			}
		},
		error: function(e){
			plus.nativeUI.closeWaiting();
			toast('网络连接失败');
		}
	})
	
}

/**
 * 搜索
 * @param {String} keywords
 */
function searchMsg(keywords){
	if(!keywords){
		toast('请输入关键字');
		return;
	}
	plus.nativeUI.showWaiting();
	var search_2 = plus.webview.create('search-2.html', 'search_2', {}, {
		keywords : keywords,
		tid : tid
	});
	search_2.addEventListener('loaded', function (){
		$(".mui-input-clear").val('');
		search_2.show('pop-in');
		plus.nativeUI.closeWaiting();
	})
}
